﻿using IdentityServer4.EntityFramework.Entities;
using Ids4.Api.Models.Dtos.IdentityResources;
using Ids4.Api.Models.Vos.IdentityResources;

namespace Ids4.Api.Application.Profiles
{
    public class IdentityResourceProfile : Profile
    {
        public IdentityResourceProfile()
        {

            CreateMap<CreateIdentityResourceDto, IdentityResource>(MemberList.None).ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => new IdentityResourceClaim { Type = x })));

            CreateMap<IdentityResource, IdentityResourceVo>(MemberList.Destination)
                .ForMember(x => x.UserClaims, opt => opt.MapFrom(src => src.UserClaims.Select(x => x.Type)));

            CreateMap<CreateIdentityResourcePropertyDto, IdentityResourceProperty>(MemberList.None);

            CreateMap<IdentityResource, IdentityResourceListVo>(MemberList.None);
        }
    }
}
